﻿using System;
using Epm.AppLogic.Framework;
using msBsc.Xsd.DataTds;
using System.Data;
using System.Linq;
using System.Text;
using msBsc.Cls;
using msBsc.AppLogic.DataAlc.cls;

namespace msBsc.AppLogic.DataAlc
{
    /// <summary>
    /// 车辆信息类
    /// </summary>
    public class CBizVehicleInfo : CustBizObject
    {
        private CDmDjkVehicleInfo m_CDmDjkVehicleInfo = new CDmDjkVehicleInfo();
        public CDmDjkCountryCity m_CDmDjkCountryCity = new CDmDjkCountryCity();
        private CDmDjkVehicleInfo oDmDjkVehicleInfo
        {
            get { return m_CDmDjkVehicleInfo; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CBizVehicleInfo()
            : base()
        {
            this.DataObj = new CDbAccess();
            this.DataObj.Init(this.m_CDmDjkVehicleInfo.DJK_VEHICLE_INFO);
            this.TableName = this.DataObj.TableName;
            this.DataObj.KeyField = this.DataObj.Fields["VEHICLE_INFO_ID"];
        }

        public CBizVehicleInfo(string QueryString)
            : base()
        {
            this.DataObj = new CDbAccess();
            this.DataObj.Init(this.m_CDmDjkVehicleInfo.DJK_VEHICLE_INFO);
            this.TableName = this.DataObj.TableName;
            this.DataObj.KeyField = this.DataObj.Fields["VEHICLE_INFO_ID"];
            SetQueryStr(QueryString);
        }

        /// <summary>
        /// 新增记录前的处理
        /// </summary>
        /// <param name="drw">新增数据行</param>
        /// <returns>true/false</returns>
        /// <remarks>
        /// 生成ID值
        /// </remarks>
        protected override bool BeforeRowAdded(DataRow drw)
        {
            if (drw[this.KeyFieldName].ToString().Length < 10)
            {
                drw[this.KeyFieldName] = this.DataObj.NewID();
            }

            return true;
        }

        /// <summary>
        /// 记录修改前检验
        /// </summary>
        /// <param name="drw">当前记录</param>
        /// <returns>>校验合法，返回值为true,否则返回false</returns>
        /// <remarks>
        /// ID不允许修改,并把此修改操作记录到BSE_MODIFY_HISTORY表中
        /// </remarks>
        protected override bool BeforeRowModified(DataRow drw)
        {
            //ID不容许修改
            if (drw[this.KeyFieldName].ToString() != drw[this.KeyFieldName, DataRowVersion.Original].ToString())
            {
                Exception e = new Exception(this.TableName + "表的主键" + this.KeyFieldName + "字段不允许被修改");
                throw e;
            }
            return true;
        }
        protected override bool BeforeRowDeletedR(DataRow drw)
        {
            //using (msBsc.AppLogic.DataAlc.CBizShpPageColumn objtem = new CBizShpPageColumn())
            //{
            //    DataSet ds = objtem.SelectByPageNo(this.GetRowStr(drw, KeyFieldName));
            //    for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--)
            //    {
            //        ds.Tables[0].Rows[i].Delete();
            //    }
            //    objtem.Update(ds);
            //} 
            return true;
        }

        protected override bool AfterRowAdded(DataRow drw)
        {
            return true;
        }

        protected override bool AfterRowModified(DataRow drw)
        {
            return true;
        }

        protected override bool AfterRowDeletedR(DataRow drw)
        {
            return true;
        }
        #region 发布车辆
        /// <summary>
        /// 地接客添加车辆
        /// </summary>
        /// <param name="djkId">地接客ID</param>
        /// <param name="name">车辆名称</param>
        /// <param name="buyTime">购买时间</param>
        /// <param name="seats">座位数</param>
        /// <param name="price">价格</param>
        /// <param name="serviceArea">服务范围</param>
        /// <param name="destinId">所在地</param>
        /// <param name="cityId">所在城市</param>
        /// <param name="countryId">所在国家</param>
        /// <param name="carType">车辆类型</param>
        /// <param name="brand">车辆品牌</param>
        /// <param name="color">颜色</param>
        /// <param name="serviceType">服务类型</param>
        /// <param name="picture">车辆图片</param>
        /// <param name="intro">车辆简介</param>
        /// <param name="shouldKnow">购买须知</param>
        /// <returns></returns>
        public string[] AddVehicleInfo(string djkId, string name, string buyTime, string seats, string price, string serviceArea, string destinId, string cityId, string countryId, string carType, string brand, string color, string serviceType, string picture, string intro, string shouldKnow)
        {
            #region 验证
            #region 非空判断
            if (string.IsNullOrEmpty(djkId) &&
                string.IsNullOrEmpty(name) &&
                string.IsNullOrEmpty(buyTime) &&
                string.IsNullOrEmpty(seats) &&
                string.IsNullOrEmpty(price) &&
                string.IsNullOrEmpty(serviceArea) &&
                string.IsNullOrEmpty(destinId) &&
                string.IsNullOrEmpty(cityId) &&
                string.IsNullOrEmpty(countryId) &&
                string.IsNullOrEmpty(carType) &&
                string.IsNullOrEmpty(brand) &&
                string.IsNullOrEmpty(color) &&
                string.IsNullOrEmpty(serviceType) &&
                string.IsNullOrEmpty(picture) &&
                string.IsNullOrEmpty(intro) &&
                string.IsNullOrEmpty(shouldKnow))
            {
                return new string[] { "FALSE", "车辆信息不能为空" };
            }
            #endregion

            #region 格式验证
            if (!CommValiCollection.IsNumber(price))
            {
                return new string[] { "FALSE", "价格只能是数字" };
            }
            if (!CommValiCollection.IsNumber(seats))
            {
                return new string[] { "FALSE", "车辆座位数只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(carType))
            {
                return new string[] { "FALSE", "车辆类型只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(brand))
            {
                return new string[] { "FALSE", "车辆品牌只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(color))
            {
                return new string[] { "FALSE", "车辆颜色只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(serviceType))
            {
                return new string[] { "FALSE", "车辆服务类型只能是正整数" };
            }
            //日期判断
            if (!CommValiCollection.IsDate(buyTime))
            {
                return new string[] { "FALSE", "车辆购买时间格式不正确" };
            }
            //车名长度判断
            if (CommValiCollection.GetStrLength(name) > 40)
            {
                return new string[] { "FALSE", "车辆名称少于40字符" };
            }
            //车辆简介长度判断
            if (intro.Length > 500)
            {
                return new string[] { "FALSE", "车辆简介少于500字符" };
            }
            //地区判断
            if (!CommValiCollection.IsGuid(destinId) ||
                !CommValiCollection.IsGuid(cityId) ||
                !CommValiCollection.IsGuid(countryId))
            {
                return new string[] { "FALSE", "车辆所属地区格式不正确" };
            }
            //购买须知长度判断
            if (shouldKnow.Length > 500)
            {
                return new string[] { "FALSE", "购买须知少于500字符" };
            }
            #endregion

            #region 非法验证
            int carColor = 1; //车辆颜色
            int.TryParse(color, out carColor);
            int adultsNum = 4; //可载人数
            int.TryParse(seats, out adultsNum);
            DateTime useTime = DateTime.Now;//上户时间
            DateTime.TryParse(buyTime, out useTime);
            int serverType = 1;//服务类型
            int.TryParse(serviceType, out serverType);
            int vehiclelBrand = 1;//车辆品牌
            int.TryParse(brand, out vehiclelBrand);
            decimal carPrice = 0;//车辆价格
            decimal.TryParse(price, out carPrice);
            int vehiclelType;
            int.TryParse(carType, out vehiclelType);

            if (int.MaxValue < adultsNum || adultsNum < 0)
            {
                return new string[] { "FALSE", "车辆座位数不正确" };
            }
            if (carPrice < 0 || carPrice > 100000000)
            {
                return new string[] { "FALSE", "车辆价格不正确" };
            }
            #endregion

            #region 验证车辆编码
            //获取车辆编码
            string vehicleCode = GetVehicleCode(destinId);
            //验证车辆编码
            if (string.IsNullOrEmpty(vehicleCode))
            {
                return new string[] { "FALSE", "生成车辆编号失败" };
            }
            int i = 0;
            while (i < 3 && SelectVehicleCode(vehicleCode).Tables[0].Rows.Count > 0)
            {
                vehicleCode = GetVehicleCode(destinId);
                i++;
            }
            if (i >= 3)
            {
                return new string[] { "FALSE", "生成车辆编号失败" };
            }
            #endregion
            #endregion

            #region 验证通过，发布车辆
            DataSet ds = new CDmDjkVehicleInfo();
            DataRow dr = ds.Tables[0].NewRow();
            dr["DJACK_ID"] = djkId;
            dr["VEHICLE_NAME"] = name;
            dr["VEHICLE_BRAND"] = vehiclelBrand;
            dr["VEHICLE_TYPE"] = vehiclelType;
            dr["VEHICLE_SEATS"] = adultsNum;
            dr["VEHICLE_BUY_TIME"] = buyTime;
            dr["VEHICLE_COLOR"] = carColor;
            dr["VEHICLE_SERVICE_TYPE"] = serverType;
            dr["VEHICLE_PRICE_DAY"] = carPrice;
            dr["VEHICLE_INTRO"] = intro;
            dr["ORDER_SHOULD_KNOW"] = shouldKnow;
            dr["VEHICLE_SERVICE_AREA"] = serviceArea;
            dr["VEHICLE_DEFAULT_PIC"] = picture;
            dr["VEHICLE_DESTINATION"] = destinId;
            dr["VEHICLE_CITY"] = cityId;
            dr["VEHICLE_COUNTRY"] = countryId;
            dr["VEHICLE_CODE"] = vehicleCode;
            dr["VEHICLE_PUBLISH_TIME"] = this.dtCurrDateTime;
            dr["VEHICLE_INFO_ID"] = this.DataObj.NewID();
            dr["VEHICLE_PUBLISHER_IP"] = msBsc.Cls.CommValiCollection.GetIp();
            dr["VEHICLE_STATUS"] = 1;
            dr["VEHICLE_IS_REVIEW"] = 1;
            dr["VEHICLE_IS_DELETED"] = 0;
            dr["VEHICLE_IS_DISPLAY"] = 1;

            ds.Tables[0].Rows.Add(dr);
            this.Update(ds);
            return new string[] { "OK", "车辆发布成功" };
            #endregion
        }
        #endregion

        #region 修改车辆信息
        /// <summary>
        /// 地接客修改车辆
        /// </summary>
        /// <param name="djkId">地接客ID</param>
        /// <param name="vehicleId">车辆ID</param>
        /// <param name="name">车辆名称</param>
        /// <param name="buyTime">购买时间</param>
        /// <param name="seats">座位数</param>
        /// <param name="price">价格</param>
        /// <param name="serviceArea">服务范围</param>
        /// <param name="destinId">所在地</param>
        /// <param name="cityId">所在城市</param>
        /// <param name="countryId">所在国家</param>
        /// <param name="carType">车辆类型</param>
        /// <param name="brand">车辆品牌</param>
        /// <param name="color">颜色</param>
        /// <param name="serviceType">服务类型</param>
        /// <param name="picture">车辆图片</param>
        /// <param name="intro">车辆简介</param>
        /// <param name="shouldKnow">购买须知</param>
        /// <returns></returns>
        public string[] EditVehicleInfo(string djkId, string vehicleId, string name, string buyTime, string seats, string price, string serviceArea, string destinId, string cityId, string countryId, string carType, string brand, string color, string serviceType, string picture, string intro, string shouldKnow)
        {
            #region 验证

            #region 非空判断
            if (string.IsNullOrEmpty(djkId) &&
                string.IsNullOrEmpty(name) &&
                string.IsNullOrEmpty(buyTime) &&
                string.IsNullOrEmpty(seats) &&
                string.IsNullOrEmpty(price) &&
                string.IsNullOrEmpty(serviceArea) &&
                string.IsNullOrEmpty(destinId) &&
                string.IsNullOrEmpty(cityId) &&
                string.IsNullOrEmpty(countryId) &&
                string.IsNullOrEmpty(carType) &&
                string.IsNullOrEmpty(brand) &&
                string.IsNullOrEmpty(color) &&
                string.IsNullOrEmpty(serviceType) &&
                string.IsNullOrEmpty(picture) &&
                string.IsNullOrEmpty(intro) &&
                string.IsNullOrEmpty(shouldKnow))
            {
                return new string[] { "FALSE", "车辆信息不能为空" };
            }
            #endregion

            #region 格式验证
            if (!CommValiCollection.IsNumber(price))
            {
                return new string[] { "FALSE", "价格只能是数字" };
            }
            if (!CommValiCollection.IsNumber(seats))
            {
                return new string[] { "FALSE", "车辆座位数只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(carType))
            {
                return new string[] { "FALSE", "车辆类型只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(brand))
            {
                return new string[] { "FALSE", "车辆品牌只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(color))
            {
                return new string[] { "FALSE", "车辆颜色只能是正整数" };
            }
            if (!CommValiCollection.IsNumber(serviceType))
            {
                return new string[] { "FALSE", "车辆服务类型只能是正整数" };
            }
            //日期判断
            if (!CommValiCollection.IsDate(buyTime))
            {
                return new string[] { "FALSE", "车辆购买时间格式不正确" };
            }
            //车名长度判断
            if (CommValiCollection.GetStrLength(name) > 40)
            {
                return new string[] { "FALSE", "车辆名称少于40字符" };
            }
            //车辆简介长度判断
            if (intro.Length > 500)
            {
                return new string[] { "FALSE", "车辆简介少于500字符" };
            }
            //地区判断
            if (!CommValiCollection.IsGuid(destinId) ||
                !CommValiCollection.IsGuid(cityId) ||
                !CommValiCollection.IsGuid(countryId))
            {
                return new string[] { "FALSE", "车辆所属地区格式不正确" };
            }
            //购买须知长度判断
            if (shouldKnow.Length > 500)
            {
                return new string[] { "FALSE", "购买须知少于500字符" };
            }
            #endregion

            #region 非法验证
            int carColor = 1; //车辆颜色
            int.TryParse(color, out carColor);
            int adultsNum = 4; //可载人数
            int.TryParse(seats, out adultsNum);
            DateTime useTime = DateTime.Now;//上户时间
            DateTime.TryParse(buyTime, out useTime);
            int serverType = 1;//服务类型
            int.TryParse(serviceType, out serverType);
            int vehiclelBrand = 1;//车辆品牌
            int.TryParse(brand, out vehiclelBrand);
            decimal carPrice = 0;//车辆价格
            decimal.TryParse(price, out carPrice);
            int vehiclelType;
            int.TryParse(carType, out vehiclelType);

            if (int.MaxValue < adultsNum || adultsNum < 0)
            {
                return new string[] { "FALSE", "车辆座位数不正确" };
            }
            if (carPrice < 0 || carPrice > 100000000)
            {
                return new string[] { "FALSE", "车辆价格不正确" };
            }
            #endregion

            #endregion

            #region 验证通过，修改车辆
            //判断该车辆是否存在
            DataSet ds = DjackGetVehicleById(vehicleId, djkId);
            if (ds.Tables[0].Rows.Count <= 0)
            {
                return new string[] { "FALSE", "该车辆不存在" };
            }
            ds.Tables[0].Rows[0]["VEHICLE_NAME"] = name;
            ds.Tables[0].Rows[0]["VEHICLE_BRAND"] = vehiclelBrand;
            ds.Tables[0].Rows[0]["VEHICLE_TYPE"] = vehiclelType;
            ds.Tables[0].Rows[0]["VEHICLE_SEATS"] = adultsNum;
            ds.Tables[0].Rows[0]["VEHICLE_COLOR"] = carColor;
            ds.Tables[0].Rows[0]["VEHICLE_SERVICE_TYPE"] = serverType;
            ds.Tables[0].Rows[0]["VEHICLE_BUY_TIME"] = buyTime;
            ds.Tables[0].Rows[0]["VEHICLE_PRICE_DAY"] = carPrice;
            ds.Tables[0].Rows[0]["VEHICLE_INTRO"] = intro;
            ds.Tables[0].Rows[0]["ORDER_SHOULD_KNOW"] = shouldKnow;
            ds.Tables[0].Rows[0]["VEHICLE_SERVICE_AREA"] = serviceArea;
            ds.Tables[0].Rows[0]["VEHICLE_DEFAULT_PIC"] = picture;
            ds.Tables[0].Rows[0]["VEHICLE_DESTINATION"] = destinId;
            ds.Tables[0].Rows[0]["VEHICLE_CITY"] = cityId;
            ds.Tables[0].Rows[0]["VEHICLE_COUNTRY"] = countryId;
            if (ds.Tables[0].Rows[0]["VEHICLE_STATUS"].ToString() == "3")
            {
                ds.Tables[0].Rows[0]["VEHICLE_STATUS"] = 1;
            }
            this.Update(ds);
            return new string[] { "TRUE", "车辆信息修改成功" };
            #endregion
        }

        public string RemoveVehicleInfo(string vehicleId)
        {
            if (string.IsNullOrEmpty(vehicleId))
            {
                return "车辆信息有误，请检查";
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("vehicleId", ParameterDirection.Input, EDbType.String, 36, vehicleId));
            parmCollection.Add(new CDbParm("djackId", ParameterDirection.Input, EDbType.String, 36, msBsc.SvRef.UserInfo.Operator));

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT * FROM DJK_VEHICLE_INFO WHERE VEHICLE_INFO_ID=@vehicleId AND DJACK_ID=@djackId", parmCollection);
            ds.Tables[0].TableName = this.TableName;

            if (ds == null || ds.Tables[0].Rows.Count != 1)
            {
                return "车辆信息有误，请检查";
            }

            if (ds.Tables[0].Rows[0]["VEHICLE_STATUS"].ToString() != "3")
            {
                return "车辆状态有误，不可删除";
            }

            ds.Tables[0].Rows[0]["VEHICLE_IS_DELETED"] = 1;
            this.Update(ds);

            return string.Empty;
        }
        #endregion

        #region 车辆分页查询
        /// <summary>
        /// 根据地接客ID查询车辆分页列表
        /// </summary>
        /// <param name="pageRows">当前页数据条数</param>
        /// <param name="pageNum">页码</param>
        /// <param name="djkId">地接客ID</param>
        /// <returns></returns>
        public DataSet GetVehicleForPageByDjkId(int pageRows, int pageNum, string djkId)
        {
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("ipagerows", ParameterDirection.Input, EDbType.String, 36, pageRows));
            parmCollection.Add(new CDbParm("ipagenum", ParameterDirection.Input, EDbType.String, 36, pageNum));
            parmCollection.Add(new CDbParm("djkid", ParameterDirection.Input, EDbType.String, 36, djkId));
            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_DJACK_VEHICLE_FOR_VIEW", parmCollection);
            return ds;
        }

        /// <summary>
        /// 车辆多条件分页查询
        /// </summary>
        /// <param name="pageRows">当前页数据条数</param>
        /// <param name="pageNum">页码</param>
        /// <param name="destionId">目的地编号</param>
        /// <param name="cityId">城市编号</param>
        /// <param name="countryId">国家编号</param>
        /// <param name="vehicleType">车辆类型</param>
        /// <param name="brand">车辆品牌</param>
        /// <param name="minprice">车辆最低价格</param>
        /// <param name="maxprice">车辆最高价格</param>
        /// <param name="minseats">车辆最少座位数</param>
        /// <param name="maxseats">车辆最多座位数</param>
        /// <param name="serviceType">服务类型</param>
        /// <returns></returns>
        public DataSet GetVehicleForPageview(int pageRows, int pageNum, string destionId, string cityId, string countryId, int vehicleType, int brand, decimal minprice, decimal maxprice, int minseats, int maxseats, int serviceType, string kw = "")
        {
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("ipagerows", ParameterDirection.Input, EDbType.String, 36, pageRows));
            parmCollection.Add(new CDbParm("ipagenum", ParameterDirection.Input, EDbType.String, 36, pageNum));
            parmCollection.Add(new CDbParm("destination", ParameterDirection.Input, EDbType.String, 36, destionId));
            parmCollection.Add(new CDbParm("cityid", ParameterDirection.Input, EDbType.String, 36, cityId));
            parmCollection.Add(new CDbParm("countryid", ParameterDirection.Input, EDbType.String, 36, countryId));
            parmCollection.Add(new CDbParm("vehicletype", ParameterDirection.Input, EDbType.String, 36, vehicleType));
            parmCollection.Add(new CDbParm("brand", ParameterDirection.Input, EDbType.String, 36, brand));
            parmCollection.Add(new CDbParm("minprice", ParameterDirection.Input, EDbType.Decimal, 36, minprice));
            parmCollection.Add(new CDbParm("maxprice", ParameterDirection.Input, EDbType.Decimal, 36, maxprice));
            parmCollection.Add(new CDbParm("minseats", ParameterDirection.Input, EDbType.String, 36, minseats));
            parmCollection.Add(new CDbParm("maxseats", ParameterDirection.Input, EDbType.String, 36, maxseats));
            parmCollection.Add(new CDbParm("serviceType", ParameterDirection.Input, EDbType.String, 36, serviceType));
            parmCollection.Add(new CDbParm("kw", ParameterDirection.Input, EDbType.String, 255, kw));
            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_VEHICLE_FOR_VIEW", parmCollection);
            return ds;
        }

        #endregion

        #region 车辆查询

        /// <summary>
        /// 下订单时查询车辆信息
        /// </summary>
        /// <param name="djkId">地接客ID</param>
        /// <returns>VEHICLE_INFO_ID：车辆ID，VEHICLE_NAME：车辆名称，VEHICLE_COLOR：车辆颜色，VEHICLE_PRICE_DAY：单价，VEHICLE_CODE：车辆编码，VEHICLE_DEFAULT_PIC：图片</returns>
        public DataSet GetVehicleForSubmitOrder(string djkId)
        {
            if (string.IsNullOrEmpty(djkId))
            {
                return null;
            }

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("DJKID", ParameterDirection.Input, EDbType.String, 36, djkId.Replace("'", "").Replace(",", "','")));

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT VEHICLE_INFO_ID,VEHICLE_NAME,VEHICLE_SERVICE_TYPE,VEHICLE_PRICE_DAY,
    VEHICLE_SEATS,VEHICLE_DEFAULT_PIC
        FROM DJK_VEHICLE_INFO 
        WHERE DJACK_ID=@DJKID and VEHICLE_IS_REVIEW=1 and VEHICLE_IS_DELETED=0 and VEHICLE_IS_DISPLAY=1", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        /// <summary>
        /// 获取车辆信息
        /// </summary>
        /// <param name="vehicleId">车辆编号</param>
        /// <param name="djkId">地接客编号</param>
        /// <param name="destinId">目的地编号</param>
        /// <param name="cityId">城市编号</param>
        /// <param name="countryId">国家编号</param>
        /// <param name="vehicleType">车辆类型</param>
        /// <param name="vehicleBrand">品牌</param>
        /// <param name="vehiclePrice">价格</param>
        /// <param name="vehicleSeats">座位数</param>
        /// <param name="serviceType">服务类型</param>
        /// <returns>CUSTOMER_NICK:用户名称，CUSTOMER_DEFAULT_PIC:用户头像，DJACK_SPECIEINFO_ID:地接客ID，DJACK_SERVICE_VOICE：服务标语，CUSTOMER_BASEINFO_MOBILE：移动电话，CUSTOMER_DISTINATION_ID：所在地编号，VEHICLE_NAME：车辆名称，VEHICLE_BRAND：车辆品牌，VEHICLE_TYPE：车辆类型，VEHICLE_SEATS：车辆座位数，VEHICLE_COLOR：车辆颜色，VEHICLE_SERVICE_TYPE：服务类型，VEHICLE_SERVICE_TIME：服务时间，VEHICLE_PRICE_DAY：价格，VEHICLE_INTRO：车辆介绍，VEHICLE_CODE：车辆编码，ORDER_SHOULD_KNOW：购买须知，VEHICLE_SERVICE_AREA：服务地区，VEHICLE_DEFAULT_PIC：车辆图片，VEHICLE_DESTINATION：车辆所在地编码，VEHICLE_CITY：车辆所在城市，VEHICLE_COUNTRY：车辆所在国家</returns>
        public DataSet GetVehicleForView(string vehicleId, string djkId, string destinId, string cityId, string countryId, string vehicleType, string vehicleBrand, string vehiclePrice, string vehicleSeats, string serviceType)
        {
            //判断是否全为空
            if (string.IsNullOrEmpty(vehicleId) &&
                string.IsNullOrEmpty(djkId) &&
                string.IsNullOrEmpty(destinId) &&
                string.IsNullOrEmpty(cityId) &&
                string.IsNullOrEmpty(countryId) &&
                string.IsNullOrEmpty(vehicleType) &&
                string.IsNullOrEmpty(vehicleBrand) &&
                string.IsNullOrEmpty(serviceType) &&
                string.IsNullOrEmpty(vehiclePrice) &&
                string.IsNullOrEmpty(vehicleSeats)
                )
            {
                return null;
            }

            //SQL语句
            StringBuilder sbSqlString = new StringBuilder();

            sbSqlString.Append(@"SELECT A.CUSTOMER_NICK,A.CUSTOMER_DEFAULT_PIC,B.DJACK_SPECIEINFO_ID,
    B.DJACK_SERVICE_VOICE,C.CUSTOMER_BASEINFO_MOBILE,C.CUSTOMER_DISTINATION_ID,D.VEHICLE_NAME,
    D.VEHICLE_BRAND,D.VEHICLE_TYPE,D.VEHICLE_SEATS,D.VEHICLE_COLOR,D.VEHICLE_SERVICE_TYPE,
    D.VEHICLE_SERVICE_TIME,D.VEHICLE_PRICE_DAY,D.VEHICLE_INTRO,D.VEHICLE_CODE,
    D.ORDER_SHOULD_KNOW,D.VEHICLE_SERVICE_AREA,D.VEHICLE_DEFAULT_PIC,D.VEHICLE_DESTINATION,D.VEHICLE_CITY,D.VEHICLE_COUNTRY
    FROM DJK_CUSTOMER_REGISTER A
    LEFT JOIN DJK_DJACK_SPECIEINFO B
    ON A.CUSTOMER_REGISTER_ID=B.DJACK_SPECIEINFO_ID
    LEFT JOIN DJK_CUSTOMER_BASEINFO C
    ON A.CUSTOMER_REGISTER_ID=C.CUSTOMER_BASEINFO_ID
    LEFT JOIN DJK_VEHICLE_INFO D
    ON B.DJACK_SPECIEINFO_ID=D.DJACK_ID
    WHERE VEHICLE_IS_DELETED = 0 AND VEHICLE_IS_DISPLAY=1 ");

            //SQL参数
            CDbParmCollection parmCollection = new CDbParmCollection();
            #region 车辆详情
            if (!string.IsNullOrEmpty(vehicleId))
            {
                sbSqlString.Append("AND D.VEHICLE_INFO_ID = @VIHICLEID ");
                parmCollection.Add(new CDbParm("VIHICLEID", ParameterDirection.Input, EDbType.String, 36, vehicleId.Replace("'", "").Replace(",", "','")));
            }
            #endregion
            #region 判断地接客
            if (!string.IsNullOrEmpty(djkId))
            {
                sbSqlString.Append("AND D.DJACK_ID = @DJKID ");
                parmCollection.Add(new CDbParm("DJKID", ParameterDirection.Input, EDbType.String, 36, djkId.Replace("'", "").Replace(",", "','")));
            }
            #endregion
            #region 判断地区信息
            if (!string.IsNullOrEmpty(destinId))
            {
                sbSqlString.Append("AND D.VEHICLE_DESTINATION = @DESTINID ");
                parmCollection.Add(new CDbParm("DESTINID", ParameterDirection.Input, EDbType.String, 36, destinId.Replace("'", "").Replace(",", "','")));
            }

            if (!string.IsNullOrEmpty(cityId))
            {
                sbSqlString.Append("AND D.VEHICLE_CITY = @CITYID ");
                parmCollection.Add(new CDbParm("CITYID", ParameterDirection.Input, EDbType.String, 36, cityId.Replace("'", "").Replace(",", "','")));
            }

            if (!string.IsNullOrEmpty(countryId))
            {
                sbSqlString.Append("AND D.VEHICLE_COUNTRY = @COUNTRYID ");
                parmCollection.Add(new CDbParm("COUNTRYID", ParameterDirection.Input, EDbType.String, 36, countryId.Replace("'", "").Replace(",", "','")));
            }
            #endregion
            #region 判断车辆信息
            if (!string.IsNullOrEmpty(vehicleType))
            {
                sbSqlString.Append("AND D.VEHICLE_TYPE = @VIHICLETYPE ");
                parmCollection.Add(new CDbParm("VIHICLETYPE", ParameterDirection.Input, EDbType.String, 36, vehicleType.Replace("'", "").Replace(",", "','")));
            }
            if (!string.IsNullOrEmpty(vehicleBrand))
            {
                sbSqlString.Append("AND D.VEHICLE_BRAND = @VIHICLEBRAND ");
                parmCollection.Add(new CDbParm("VIHICLEBRAND", ParameterDirection.Input, EDbType.String, 36, vehicleBrand.Replace("'", "").Replace(",", "','")));
            }
            if (!string.IsNullOrEmpty(serviceType))
            {
                sbSqlString.Append("AND D.VEHICLE_SERVICE_TYPE = @SERVICETYPE ");
                parmCollection.Add(new CDbParm("SERVICETYPE", ParameterDirection.Input, EDbType.String, 36, serviceType.Replace("'", "").Replace(",", "','")));
            }
            if (!string.IsNullOrEmpty(vehiclePrice))
            {
                sbSqlString.Append("AND D. VEHICLE_PRICE_DAY = @VIHICLEPRICE ");
                parmCollection.Add(new CDbParm("VIHICLEPRICE", ParameterDirection.Input, EDbType.String, 36, serviceType.Replace("'", "").Replace(",", "','")));
            }
            if (!string.IsNullOrEmpty(vehicleSeats))
            {
                sbSqlString.Append("AND D.VEHICLE_SEATS = @VIHICLESEATS ");
                parmCollection.Add(new CDbParm("VIHICLESEATS", ParameterDirection.Input, EDbType.String, 36, serviceType.Replace("'", "").Replace(",", "','")));
            }
            #endregion

            sbSqlString.Append("ORDER BY D.VEHICLE_PUBLISH_TIME DESC");
            //执行查询
            DataSet ds = this.DataObj.QueryBySQL(sbSqlString.ToString(), parmCollection);

            return ds;
        }


        /// <summary>
        /// 车辆详情
        /// </summary>
        /// <param name="vehicleId">车辆ID</param>
        /// <returns>CUSTOMER_NICK：用户昵称，CUSTOMER_DEFAULT_PIC：用户头像，DJACK_SPECIEINFO_ID：地接客ID,DJACK_SERVICE_VOICE：服务标语，CUSTOMER_BASEINFO_GENDER：性别，CUSTOMER_BASEINFO_MOBILE：联系电话，CUSTOMER_DISTINATION_ID：所在地编号，CUSTOMER_CITY_ID：所在城市，CUSTOMER_COUNTRY_ID：所在国家，CUSTOMER_BASEINFO_INTRO：地接客简介，VEHICLE_INFO_ID:车辆ID,VEHICLE_NAME：车辆名称，VEHICLE_BRAND：车辆品牌，VEHICLE_SEATS：座位数，VEHICLE_PRICE_DAY：价格，VEHICLE_INTRO：车辆简介，VEHICLE_CODE：车辆编码，VEHICLE_SERVICE_AREA：车辆服务范围，VEHICLE_SERVICE_TYPE:车辆服务类型，ORDER_SHOULD_KNOW：购买须知，VEHICLE_DEFAULT_PIC：车辆图片，DESTINATIONNAME：所在地名称，CITYNAME：城市名称，COUNTRYNAME：国家名称</returns>
        public DataSet GetVehicleById(string vehicleId)
        {
            if (string.IsNullOrEmpty(vehicleId))
            {
                return null;
            }

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("VEHICLEID", ParameterDirection.Input, EDbType.String, 36, vehicleId.Replace("'", "").Replace(",", "','")));

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT T3.*,A3.COUNTRY_CITY_NME DESTINATIONNAME FROM
    (SELECT T2.*,A2.COUNTRY_CITY_NME CITYNAME FROM
    (SELECT T1.*,A1.COUNTRY_CITY_NME COUNTRYNAME FROM
    (SELECT A.CUSTOMER_NICK,A.CUSTOMER_DEFAULT_PIC,B.DJACK_SPECIEINFO_ID,B.DJACK_SERVICE_VOICE,
    C.CUSTOMER_BASEINFO_GENDER,C.CUSTOMER_BASEINFO_MOBILE,
	C.CUSTOMER_DISTINATION_ID,C.CUSTOMER_CITY_ID,C.CUSTOMER_COUNTRY_ID,C.CUSTOMER_BASEINFO_INTRO,
	D.VEHICLE_INFO_ID,D.VEHICLE_NAME,D.VEHICLE_BRAND,D.VEHICLE_SEATS,
    D.VEHICLE_PRICE_DAY,D.VEHICLE_INTRO,D.VEHICLE_CODE,D.VEHICLE_SERVICE_AREA,D.VEHICLE_SERVICE_TYPE,
    D.ORDER_SHOULD_KNOW,D.VEHICLE_DEFAULT_PIC
    FROM DJK_CUSTOMER_REGISTER A
    LEFT JOIN DJK_DJACK_SPECIEINFO B
    ON A.CUSTOMER_REGISTER_ID=B.DJACK_SPECIEINFO_ID
    LEFT JOIN DJK_CUSTOMER_BASEINFO C
    ON A.CUSTOMER_REGISTER_ID=C.CUSTOMER_BASEINFO_ID
    LEFT JOIN DJK_VEHICLE_INFO D
    ON B.DJACK_SPECIEINFO_ID=D.DJACK_ID
    WHERE D.VEHICLE_IS_DELETED = 0 AND D.VEHICLE_IS_DISPLAY=1 AND D.VEHICLE_INFO_ID=@VEHICLEID) T1
	LEFT JOIN DJK_COUNTRY_CITY A1 
	ON T1.CUSTOMER_COUNTRY_ID=A1.COUNTRY_CITY_ID) T2
	LEFT JOIN DJK_COUNTRY_CITY A2
	ON T2.CUSTOMER_CITY_ID=A2.COUNTRY_CITY_ID) T3
	LEFT JOIN DJK_COUNTRY_CITY A3
	ON T3.CUSTOMER_DISTINATION_ID=A3.COUNTRY_CITY_ID", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        /// <summary>
        /// 地接客查询自己车辆信息详情
        /// </summary>
        /// <param name="vehicleId">车辆ID</param>
        /// <returns></returns>
        public DataSet DjackGetVehicleById(string vehicleId, string djackid)
        {
            if (string.IsNullOrEmpty(djackid))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            string queryStr = "";
            if (!string.IsNullOrEmpty(vehicleId))
            {
                parmCollection.Add(new CDbParm("DJACKID", ParameterDirection.Input, EDbType.String, 36, djackid));
                queryStr += " AND A.VEHICLE_INFO_ID=@VEHICLEID ";
            }
            parmCollection.Add(new CDbParm("VEHICLEID", ParameterDirection.Input, EDbType.String, 36, vehicleId));


            DataSet ds = this.DataObj.QueryBySQL(@"SELECT B.COUNTRY_CITY_NME DESTINATIONNAME,C.COUNTRY_CITY_NME CITYNAME,D.COUNTRY_CITY_NME COUNTRYNAME,A.VEHICLE_INFO_ID,A.VEHICLE_NAME,A.VEHICLE_BUY_TIME,A.VEHICLE_SEATS,A.VEHICLE_PRICE_DAY,A.VEHICLE_SERVICE_AREA,
    A.VEHICLE_TYPE,A.VEHICLE_BRAND,A.VEHICLE_COLOR,A.VEHICLE_SERVICE_TYPE,A.VEHICLE_DEFAULT_PIC,
    A.VEHICLE_INTRO,A.ORDER_SHOULD_KNOW,A.VEHICLE_STATUS,A.VEHICLE_DESTINATION,A.VEHICLE_CITY,A.VEHICLE_COUNTRY,A.VEHICLE_REFRESH_DT
    FROM DJK_VEHICLE_INFO A
	left join DJK_COUNTRY_CITY B on A.VEHICLE_COUNTRY=B.COUNTRY_CITY_ID
	left join DJK_COUNTRY_CITY C on A.VEHICLE_CITY=C.COUNTRY_CITY_ID
	left join DJK_COUNTRY_CITY D on A.VEHICLE_DESTINATION=D.COUNTRY_CITY_ID
    WHERE A.VEHICLE_IS_DELETED=0 AND A.VEHICLE_IS_DISPLAY=1 AND DJACK_ID=@DJACKID" + queryStr, parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        /// <summary>
        /// 查询车辆信息
        /// </summary>
        /// <param name="djkId">车辆ID</param>
        /// <returns></returns>
        public DataSet GetVehicleByIds(string vehicleId)
        {
            if (string.IsNullOrEmpty(vehicleId))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("VEHICLEID", ParameterDirection.Input, EDbType.String, 36, vehicleId.Replace("'", "").Replace(",", "','")));
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT T3.*,D.COUNTRY_CITY_NME DESTINNAME FROM
    (SELECT T2.*,C.COUNTRY_CITY_NME CITYNAME FROM 
    (SELECT T1.*,B.COUNTRY_CITY_NME COUNTRYNAME FROM
    (SELECT * FROM DJK_VEHICLE_INFO A WHERE A.VEHICLE_INFO_ID=@VEHICLEID) T1
    LEFT JOIN DJK_COUNTRY_CITY B
    ON T1.VEHICLE_COUNTRY=B.COUNTRY_CITY_ID) T2
    LEFT JOIN DJK_COUNTRY_CITY C
    ON T2.VEHICLE_CITY=C.COUNTRY_CITY_ID) T3
    LEFT JOIN DJK_COUNTRY_CITY D
    ON T3.VEHICLE_DESTINATION=D.COUNTRY_CITY_ID", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        /// <summary>
        /// 根据ID查询信息
        /// </summary>
        /// <param name="djkId">地接客ID</param>
        /// <param name="vehicleId">车辆ID</param>
        /// <returns></returns>
        public DataSet SelectByIds(string djackId, string vehicleId)
        {
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("djackid", ParameterDirection.Input, EDbType.String, 36, djackId));
            parmCollection.Add(new CDbParm("vehicleid", ParameterDirection.Input, EDbType.String, 36, vehicleId));
            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_DJACK_PERSON_FOR_VIEW", parmCollection);
            return ds;
        }

        #endregion

        #region 车辆其他相关信息
        string vehicleEnum = @"{'enumName':'$enumName$','enumValue':'$enumVlue$'}";
        /// <summary>
        /// 获取车辆类型
        /// </summary>
        /// <returns></returns>
        public DataTable GetVehicleType()
        {
            string[] arrCarType = Enum.GetNames(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleTypeEnum));
            DataTable dt = new DataTable();
            DataColumn dc1 = new DataColumn("enum_Name");
            DataColumn dc2 = new DataColumn("enum_Value");
            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            //var items = Enum.GetValues(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleTypeEnum));

            //for (int i = 0; i < items.Length; i++)
            //{
            //    DataRow dr = dt.NewRow();
            //    dr["enum_Value"] = items[i];
            //    dr["enum_Name"] = Enum.GetName(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleTypeEnum), items[i]);
            //    dt.Rows.Add(dr);
            //}

            for (int i = 0; i < arrCarType.Length; i++)
            {
                DataRow dr = dt.NewRow();
                dr["enum_Name"] = arrCarType[i];
                dr["enum_Value"] = Convert.ToInt32(Enum.Parse(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleTypeEnum), arrCarType[i])).ToString();
                dt.Rows.Add(dr);
            }
            return dt;
        }

        /// <summary>
        /// 得到车辆品牌
        /// </summary>
        /// <returns></returns>
        public DataTable GetVehicleBrand()
        {
            string[] arrCarBrand = Enum.GetNames(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleBrandEnum));
            DataTable dt = new DataTable();
            DataColumn dc1 = new DataColumn("enum_Name");
            DataColumn dc2 = new DataColumn("enum_Value");
            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            for (int i = 0; i < arrCarBrand.Length; i++)
            {
                DataRow dr = dt.NewRow();
                dr["enum_Name"] = arrCarBrand[i];
                dr["enum_Value"] = Convert.ToInt32(Enum.Parse(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleBrandEnum), arrCarBrand[i])).ToString();
                dt.Rows.Add(dr);
            }
            return dt;
        }


        /// <summary>
        /// 得到车辆颜色
        /// </summary>
        /// <returns></returns>
        public DataTable GetVehicleColor()
        {
            string[] arrCarColor = Enum.GetNames(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleColorEnum));
            DataTable dt = new DataTable();
            DataColumn dc1 = new DataColumn("enum_Name");
            DataColumn dc2 = new DataColumn("enum_Value");
            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            for (int i = 0; i < arrCarColor.Length; i++)
            {
                DataRow dr = dt.NewRow();
                dr["enum_Name"] = arrCarColor[i];
                dr["enum_Value"] = Convert.ToInt32(Enum.Parse(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleColorEnum), arrCarColor[i])).ToString();
                dt.Rows.Add(dr);
            }
            return dt;
        }


        /// <summary>
        /// 生成车辆编号
        /// </summary>
        /// <param name="areaId">地区编号</param>
        /// <returns>车辆编号</returns>
        public string GetVehicleCode(string destinId)
        {
            string destination = GetOneAreaInfo(destinId);
            //生成数字字符集合
            char[] numArray = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
            //实例化随机种子
            Random rand = new Random();
            //定义车辆编号
            StringBuilder sb = new StringBuilder(destination);
            //生成车辆编号数字组合
            for (int i = 0; i < 6; i++)
            {
                sb.Append(numArray[rand.Next(0, 10)]);
            }
            //返回车辆编码
            return sb.ToString();
        }

        /// <summary>
        /// 车辆所在地区缩写
        /// </summary>
        /// <param name="areaId">目的地编号</param>
        /// <returns>地区缩写</returns>
        public string GetOneAreaInfo(string destinId)
        {
            if (!string.IsNullOrEmpty(destinId))
            {
                DataSet ds = this.DataObj.QueryBySQL(@"SELECT CITY_SORT_NME FROM DJK_COUNTRY_CITY WHERE COUNTRY_CITY_ID='" + destinId + "'");
                return ds.Tables[0].Rows.Count <= 0 ? string.Empty : ds.Tables[0].Rows[0]["CITY_SORT_NME"].ToString();
            }
            return string.Empty;
        }

        /// <summary>
        /// 查询车辆编码信息
        /// </summary>
        /// <param name="vehicleCode">车辆编码</param>
        /// <returns></returns>
        public DataSet SelectVehicleCode(string vehicleCode)
        {
            if (string.IsNullOrEmpty(vehicleCode))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("VEHICLECODE", ParameterDirection.Input, EDbType.String, 36, vehicleCode.Replace("'", "").Replace(",", "','")));

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT 1 FROM DJK_VEHICLE_INFO WHERE VEHICLE_CODE=@VEHICLECODE", parmCollection);
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        #endregion

        /// <summary>
        /// 获取车辆列表
        /// </summary>
        /// <param name="vehicleStatus"></param>
        /// <param name="starTime"></param>
        /// <param name="stopTime"></param>
        /// <param name="vehicleName"></param>
        /// <returns></returns>
        public DataSet GetVehicleList(string vehicleStatus, string starTime, string stopTime, string vehicleName)
        {
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("vechielstatus", ParameterDirection.Input, EDbType.String, 2, vehicleStatus));
            parmCollection.Add(new CDbParm("starttime", ParameterDirection.Input, EDbType.String, 100, starTime));
            parmCollection.Add(new CDbParm("stoptime", ParameterDirection.Input, EDbType.String, 100, stopTime));
            parmCollection.Add(new CDbParm("vname", ParameterDirection.Input, EDbType.String, 100, vehicleName));
            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_VEHICLE_INFO_FOR_VALID", parmCollection);

            ds.Tables[0].Columns.Add("VEHICLE_BRAND_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_TYPE_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_COLOR_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_SERVICE_TYPE_NAME", typeof(string));

            for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--)
            {
                ds.Tables[0].Rows[i]["VEHICLE_BRAND_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleBrandEnum), ds.Tables[0].Rows[i]["VEHICLE_BRAND"]);
                ds.Tables[0].Rows[i]["VEHICLE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_TYPE"]);
                ds.Tables[0].Rows[i]["VEHICLE_COLOR_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleColorEnum), ds.Tables[0].Rows[i]["VEHICLE_COLOR"]);
                ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.ServiceTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE"]);
            }
            return ds;
        }

        public System.Collections.Generic.Dictionary<string, string> dicQuery = new System.Collections.Generic.Dictionary<string, string>();

        public string GetQueryStr(string strpKey, string strpVal, bool blReplace = true)
        {
            return "";
        }

        public void SetQueryStr(string strpQuery)
        {
            System.Collections.Generic.List<string[]> lsTem = (from p in strpQuery.Split('&')
                                                               where p.IndexOf("=") != -1
                                                               select
                                                               p.Split('=')).Distinct().ToList();
            if (lsTem.Count > 0)
            {
                lsTem.ForEach(delegate(string[] item)
                {
                    dicQuery.Add(item[0], item[1]);
                });
            }
        }

        public string strSorting = "";
        public string strNeedSql = "";
        public int iCurrPageNum = 1;

        /// <summary>
        /// 手机端多条件查询
        /// </summary>
        /// <param name="CurrPageNum"></param>
        /// <param name="strPageRowsCount"></param>
        /// <param name="strSort"></param>
        /// <param name="destionId"></param>
        /// <param name="cityId"></param>
        /// <param name="countryId"></param>
        /// <param name="vehicleType"></param>
        /// <param name="brand"></param>
        /// <param name="minprice"></param>
        /// <param name="maxprice"></param>
        /// <param name="minseats"></param>
        /// <param name="maxseats"></param>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        public string GetVehicleList(string CurrPageNum, string strPageRowsCount, string strSort, string destionId, string cityId, string countryId, int vehicleType, int brand, decimal minprice, decimal maxprice, int minseats, int maxseats, int serviceType, string custFilter)
        {
            destionId = string.IsNullOrEmpty(destionId) || destionId == "0" ? "" : destionId;

            CurrPageNum = string.IsNullOrEmpty(CurrPageNum) ? "1" : CurrPageNum;
            strPageRowsCount = string.IsNullOrEmpty(strPageRowsCount) ? "20" : strPageRowsCount;

            using (Epm.AppLogic.Framework.CDbAccess oCDbAccess = new Epm.AppLogic.Framework.CDbAccess())
            {
                CDbParmCollection parmCollection = new CDbParmCollection();
                parmCollection.Add(new CDbParm("destination", ParameterDirection.Input, EDbType.String, 36, destionId));
                parmCollection.Add(new CDbParm("cityid", ParameterDirection.Input, EDbType.String, 36, cityId));
                parmCollection.Add(new CDbParm("countryid", ParameterDirection.Input, EDbType.String, 36, countryId));
                parmCollection.Add(new CDbParm("vehicletype", ParameterDirection.Input, EDbType.String, 36, vehicleType));
                parmCollection.Add(new CDbParm("brand", ParameterDirection.Input, EDbType.String, 36, brand));
                parmCollection.Add(new CDbParm("minprice", ParameterDirection.Input, EDbType.Decimal, 36, minprice));
                parmCollection.Add(new CDbParm("maxprice", ParameterDirection.Input, EDbType.Decimal, 36, maxprice));
                parmCollection.Add(new CDbParm("minseats", ParameterDirection.Input, EDbType.String, 36, minseats));
                parmCollection.Add(new CDbParm("maxseats", ParameterDirection.Input, EDbType.String, 36, maxseats));
                parmCollection.Add(new CDbParm("serviceType", ParameterDirection.Input, EDbType.String, 36, serviceType));
                parmCollection.Add(new CDbParm("custfilter", ParameterDirection.Input, EDbType.String, 255, custFilter.Replace("'", "").Replace(",", "','")));

                DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_VEHICLE_FOR_MOBILE", parmCollection);


                string strjsontem1 = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", ""
                    , (CurrPageNum == string.Empty ? iCurrPageNum : int.Parse(CurrPageNum))
                    , (strPageRowsCount == string.Empty ? 20 : int.Parse(strPageRowsCount))
                    , (strSort == string.Empty ? strSorting : strSort));

                return strjsontem1;
            }
        }

        /// <summary>
        /// 车辆 刷新
        /// </summary>
        /// <param name="djkId">地接客ID</param>
        /// <param name="vehicleId">车辆ID(可选 单个车辆时传入车辆ID，全部刷新不填)</param>
        /// <returns></returns>
        public string RefreshDatetime(string djkId, string vehicleId = null)
        {
            //判断该车辆是否存在
            DataSet ds = DjackGetVehicleById(vehicleId, djkId);
            if (ds.Tables[0].Rows.Count <= 0)
            {
                return "FALSE,该车辆不存在";
            }

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                //判断 今天是否已经刷新过了，如果刷新将不会在刷新
                if (string.IsNullOrEmpty(item["VEHICLE_REFRESH_DT"].ToString()) ||
                    Convert.ToDateTime(item["VEHICLE_REFRESH_DT"]).Date.CompareTo(this.dtCurrDateTime.Date) < 0)
                {
                    item["VEHICLE_REFRESH_DT"] = this.dtCurrDateTime;
                }
                else
                {
                    return string.Format("FALSE,{0}:该车辆今日已经刷新明天再来吧", item["VEHICLE_NAME"]);
                }
            }

            this.Update(ds);

            return "TRUE,车辆刷新成功";
        }

        /// <summary>
        /// 获取车辆信息
        /// </summary>
        /// <param name="vehicleIds">车辆编号</param>
        /// <returns>DataSet</returns>
        /// Author:蒲崇彬
        /// Creation date:2014-6-12 15:35
        public DataSet GetVehicleInfo(string vehicleIds)
        {

            string[] productsId = vehicleIds.Split('|');
            if (productsId.Length < 1)
            {
                return null;
            }
            System.Text.StringBuilder sbSql = new System.Text.StringBuilder("SELECT VEHICLE_INFO_ID PRODUCT_ID,VEHICLE_NAME PRODUCT_NAME,VEHICLE_DEFAULT_PIC PRODUCT_PIC,VEHICLE_PRICE_DAY PRODUCT_PRICE,DJACK_ID PERSON_ID,VEHICLE_SEATS PRODUCT_SEATS,VEHICLE_SERVICE_TYPE PRODUCT_SERVICE_TYPE FROM DJK_VEHICLE_INFO ");

            sbSql.Append(" WHERE VEHICLE_INFO_ID= '" + productsId[0] + "' ");
            for (int i = productsId.Length - 1; i > 0; i--)
            {
                if (!string.IsNullOrEmpty(productsId[i]))
                {
                    sbSql.Append(" OR VEHICLE_INFO_ID= '" + productsId[i] + "' ");
                }
            }

            return this.DataObj.QueryBySQL(sbSql.ToString());
        }
        /// <summary>
        /// 获取车辆信息 订单信息
        /// </summary>
        /// <param name="vehicleIds">车辆编号</param>
        /// <returns>DataSet</returns>
        /// Author:蒲崇彬
        /// Creation date:2014-6-16 15:35
        public DataSet GetUserCarInfo(string carID)
        {
            if (string.IsNullOrEmpty(carID))
            {
                return null;
            }

            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("carID", ParameterDirection.Input, EDbType.String, 36, carID));

            return this.DataObj.QueryBySQL(@"SELECT U.CUSTOMER_NICK,U.CUSTOMER_DEFAULT_PIC,C.* FROM 
	 (SELECT VEHICLE_INFO_ID,VEHICLE_NAME,VEHICLE_SERVICE_TYPE,VEHICLE_PRICE_DAY,
    VEHICLE_SEATS,VEHICLE_DEFAULT_PIC,DJACK_ID FROM DJK_VEHICLE_INFO WHERE VEHICLE_INFO_ID=@carID) C
	 LEFT JOIN DJK_CUSTOMER_REGISTER(NOLOCK) U ON C.DJACK_ID=U.CUSTOMER_REGISTER_ID", parmCollection);
        }

        /// <summary>
        /// 判断地接客是否发布车辆信息
        /// </summary>
        /// <param name="djackId"></param>
        /// <returns></returns>
        public bool DjackIsPushVehicle(string djackId)
        {
            CDbParmCollection parmColletion = new CDbParmCollection();
            parmColletion.Add(new CDbParm("djkId", ParameterDirection.Input, EDbType.String, 36, djackId.Replace(",", "','").Replace("'", "")));

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT 1 FROM DJK_VEHICLE_INFO A WHERE A.DJACK_ID=@djkId", parmColletion);

            return ds.Tables[0].Rows.Count > 0;
        }

        /// <summary>
        /// 平台给地接客添加车辆
        /// </summary>
        /// <param name="djkId">地接客Id</param>
        /// <param name="name">车辆名称</param>
        /// <param name="buyTime">购买时间</param>
        /// <param name="seats">座位数</param>
        /// <param name="price">价格</param>
        /// <param name="serviceArea">服务范围</param>
        /// <param name="carType">车辆类型</param>
        /// <param name="brand">车辆品牌</param>
        /// <param name="color">车辆颜色</param>
        /// <param name="serviceType">服务类型</param>
        /// <param name="picture">车辆图片</param>
        /// <param name="publisherId">发布人ID</param>
        /// <param name="vehicleNumber">车牌号</param>
        /// <returns>发布结果</returns>
        ///  Author:任延华
        ///  Creation date:2014-9-1
        public string AddVehicle(string djkId, string name, string buyTime, string seats, string price, string serviceArea, string carType, string brand, string color, string serviceType, string picture, string publisherId, string vehicleNumber)
        {
            #region 验证
            #region 非空判断
            if (string.IsNullOrEmpty(djkId) &&
                string.IsNullOrEmpty(name) &&
                string.IsNullOrEmpty(buyTime) &&
                string.IsNullOrEmpty(seats) &&
                string.IsNullOrEmpty(price) &&
                string.IsNullOrEmpty(serviceArea) &&
                string.IsNullOrEmpty(carType) &&
                string.IsNullOrEmpty(brand) &&
                string.IsNullOrEmpty(color) &&
                string.IsNullOrEmpty(serviceType) &&
                string.IsNullOrEmpty(publisherId) &&
                string.IsNullOrEmpty(vehicleNumber) &&
                string.IsNullOrEmpty(picture))
            {
                return "车辆信息不能为空";
            }
            #endregion

            #region 格式验证
            if (!CommValiCollection.IsNumber(price))
            {
                return "价格只能是数字";
            }
            if (!CommValiCollection.IsNumber(seats))
            {
                return "车辆座位数只能是正整数";
            }
            //日期判断
            if (!CommValiCollection.IsDate(buyTime))
            {
                return "车辆购买时间格式不正确";
            }
            //车名长度判断
            if (CommValiCollection.GetStrLength(name) > 40)
            {
                return "车辆名称少于40字符";
            }
            #endregion

            #region 非法验证
            int carColor = 1; //车辆颜色
            int.TryParse(color, out carColor);
            int adultsNum = 4; //可载人数
            int.TryParse(seats, out adultsNum);
            DateTime useTime = DateTime.Now;//上户时间
            DateTime.TryParse(buyTime, out useTime);
            int serverType = 1;//服务类型
            int.TryParse(serviceType, out serverType);
            int vehiclelBrand = 1;//车辆品牌
            int.TryParse(brand, out vehiclelBrand);
            decimal carPrice = 0;//车辆价格
            decimal.TryParse(price, out carPrice);
            int vehiclelType;
            int.TryParse(carType, out vehiclelType);

            if (int.MaxValue < adultsNum || adultsNum <= 0)
            {
                return "车辆座位数不正确";
            }
            if (carPrice <= 0 || carPrice > 100000000)
            {
                return "车辆价格不正确";
            }
            #endregion

            #region 验证车辆编码
            //获取车辆编码
            //获取代理的所属地
            string vehicleCode = "";
            string countryId = "";
            string cityId = "";
            string destinId = "";
            
            using (CBizCustomerBaseInfo baseInfo = new CBizCustomerBaseInfo())
            {
                DataSet djkDs = baseInfo.GetProxyDestin(djkId);
                if (djkDs != null && djkDs.Tables[0].Rows.Count > 0)
                {
                    destinId = djkDs.Tables[0].Rows[0]["AGENT_DISTINATION_ID"].ToString();
                    cityId = djkDs.Tables[0].Rows[0]["AGENT_CITY_ID"].ToString();
                    countryId = djkDs.Tables[0].Rows[0]["AGENT_COUNTRY_ID"].ToString();
                    vehicleCode = GetVehicleCode(destinId);
                }
            }
            ////验证车辆编码
            if (string.IsNullOrEmpty(vehicleCode))
            {
                return "生成车辆编号失败";
            }
            int i = 0;
            while (i < 3 && SelectVehicleCode(vehicleCode).Tables[0].Rows.Count > 0)
            {
                vehicleCode = GetVehicleCode(destinId);
                i++;
            }
            if (i >= 3)
            {
                return "生成车辆编号失败";
            }
            #endregion
            #endregion

            #region 验证通过，发布车辆
            DataSet ds = new CDmDjkVehicleInfo();
            DataRow dr = ds.Tables[0].NewRow();
            dr["DJACK_ID"] = djkId;
            dr["VEHICLE_NAME"] = name;
            dr["VEHICLE_BRAND"] = vehiclelBrand;
            dr["VEHICLE_TYPE"] = vehiclelType;
            dr["VEHICLE_SEATS"] = adultsNum;
            dr["VEHICLE_BUY_TIME"] = buyTime;
            dr["VEHICLE_COLOR"] = carColor;
            dr["VEHICLE_SERVICE_TYPE"] = serverType;
            dr["VEHICLE_PRICE_DAY"] = carPrice;
            dr["VEHICLE_INTRO"] = "";
            dr["ORDER_SHOULD_KNOW"] = "";
            dr["VEHICLE_SERVICE_AREA"] = serviceArea;
            dr["VEHICLE_DEFAULT_PIC"] = picture;
            dr["VEHICLE_DESTINATION"] = destinId;
            dr["VEHICLE_CITY"] = cityId;
            dr["VEHICLE_COUNTRY"] = countryId;
            dr["VEHICLE_CODE"] = vehicleCode;
            dr["VEHICLE_PUBLISH_TIME"] = this.dtCurrDateTime;
            dr["VEHICLE_INFO_ID"] = this.DataObj.NewID();
            dr["VEHICLE_PUBLISHER_IP"] = msBsc.Cls.CommValiCollection.GetIp();
            dr["VEHICLE_REFRESH_DT"] = this.dtCurrDateTime;
            dr["VEHICLE_STATUS"] = 2;
            dr["VEHICLE_IS_REVIEW"] = 1;
            dr["VEHICLE_IS_DELETED"] = 0;
            dr["VEHICLE_IS_DISPLAY"] = 1;
            dr["PUBLISHER_ID"] = publisherId;
            dr["LICENSE_PLATE_NUMBER"] = vehicleNumber;
            dr["RELEASE_TYPE"] = 1;

            ds.Tables[0].Rows.Add(dr);
            this.Update(ds);
            #endregion
            return "OK";
        }

        /// <summary>
        /// 判断 该车辆是否属于该地接客
        /// </summary>
        /// <param name="djkId">地接客id</param>
        /// <param name="vehicleId">车辆id</param>
        /// <returns>bool</returns>
        ///  Author:蒲崇彬
        ///  Creation date:2015-9-8
        public bool GetVhicleByUser(string djkId, string vehicleId)
        {

            if (string.IsNullOrEmpty(djkId) || string.IsNullOrEmpty(vehicleId))
            {
                return false;
            }
            CDbParmCollection parmColletion = new CDbParmCollection();
            parmColletion.Add(new CDbParm("djkId", ParameterDirection.Input, EDbType.String, 36, djkId.Trim()));
            parmColletion.Add(new CDbParm("vehicleId", ParameterDirection.Input, EDbType.String, 36, vehicleId.Trim()));
            DataSet ds = this.DataObj.QueryBySQL(@"SELECT 1 FROM DJK_VEHICLE_INFO  WHERE DJACK_ID=@djkId AND VEHICLE_INFO_ID=@vehicleid", parmColletion);

            return ds != null && ds.Tables[0].Rows.Count >0;
        }


        /// <summary>
        /// 查询新版地接客的车辆
        /// </summary>
        /// <param name="destination">目的地</param>
        /// <param name="cityid">城市</param>
        /// <param name="countryid">国家</param>
        /// <param name="brand">车辆品牌</param>
        /// <param name="minseats">最小座位数</param>
        /// <param name="maxseats">最大座位数</param>
        /// <param name="vehicleNumber">车牌号</param>
        /// <param name="proxy">代理人名称</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="proxyId">代理人id，代理查询的时候才传</param>
        /// <returns>车辆数据集</returns>
        public DataSet GetNewVehicleList(string destinationId, string cityId, string countryId, int brand, int minseats, int maxseats, string vehicleNumber, string proxy, string startTime, string endTime,string proxyId="")
        {
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("destination", ParameterDirection.Input, EDbType.String, 36, destinationId));
            parmCollection.Add(new CDbParm("cityid", ParameterDirection.Input, EDbType.String, 36, cityId));
            parmCollection.Add(new CDbParm("countryid", ParameterDirection.Input, EDbType.String, 36, countryId));
            parmCollection.Add(new CDbParm("brand", ParameterDirection.Input, EDbType.String, 3, brand));
            parmCollection.Add(new CDbParm("minseats", ParameterDirection.Input, EDbType.String, 3, minseats));
            parmCollection.Add(new CDbParm("maxseats", ParameterDirection.Input, EDbType.String, 3, maxseats));
            parmCollection.Add(new CDbParm("vehicleNumber", ParameterDirection.Input, EDbType.String, 15, vehicleNumber));
            parmCollection.Add(new CDbParm("proxy", ParameterDirection.Input, EDbType.String, 50, proxy));
            parmCollection.Add(new CDbParm("startTime", ParameterDirection.Input, EDbType.String, 36, startTime));
            parmCollection.Add(new CDbParm("endTime", ParameterDirection.Input, EDbType.String, 36, endTime));
            parmCollection.Add(new CDbParm("proxyId", ParameterDirection.Input, EDbType.String, 36, proxyId));
            DataSet ds = this.DataObj.QueryBySP("DJK_SELECT_VEHICLE_FOR_VIEW_NEW", parmCollection);

            ds.Tables[0].Columns.Add("VEHICLE_BRAND_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_TYPE_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_COLOR_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_SERVICE_TYPE_NAME", typeof(string));

            for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--)
            {
                ds.Tables[0].Rows[i]["VEHICLE_BRAND_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleBrandEnum), ds.Tables[0].Rows[i]["VEHICLE_BRAND"]);
                ds.Tables[0].Rows[i]["VEHICLE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_TYPE"]);
                ds.Tables[0].Rows[i]["VEHICLE_COLOR_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleColorEnum), ds.Tables[0].Rows[i]["VEHICLE_COLOR"]);
                ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.ServiceTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE"]);
            }
            return ds;
        }

        /// <summary>
        /// 获取新版车辆信息
        /// </summary>
        /// <param name="vehicleId">车辆Id</param>
        /// <returns></returns>
        ///  Author:任延华
        ///  Creation date:2015-9-11
        public DataSet GetNewVehicleInfo(string vehicleId)
        { 
            if (string.IsNullOrEmpty(vehicleId))
            {
                return null;
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("vehicleId", ParameterDirection.Input, EDbType.String, 36, vehicleId));

            DataSet ds = this.DataObj.QueryBySQL(@"SELECT VEHICLE_NAME,VEHICLE_INFO_ID,LICENSE_PLATE_NUMBER,VEHICLE_BUY_TIME,VEHICLE_SEATS,VEHICLE_PRICE_DAY,VEHICLE_SERVICE_AREA,VEHICLE_TYPE,VEHICLE_BRAND,VEHICLE_COLOR,VEHICLE_SERVICE_TYPE,VEHICLE_DEFAULT_PIC FROM DJK_VEHICLE_INFO WHERE VEHICLE_INFO_ID=@vehicleId", parmCollection);
            ds.Tables[0].Columns.Add("VEHICLE_BRAND_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_TYPE_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_COLOR_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_SERVICE_TYPE_NAME", typeof(string));

            for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--)
            {
                ds.Tables[0].Rows[i]["VEHICLE_BRAND_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleBrandEnum), ds.Tables[0].Rows[i]["VEHICLE_BRAND"]);
                ds.Tables[0].Rows[i]["VEHICLE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_TYPE"]);
                ds.Tables[0].Rows[i]["VEHICLE_COLOR_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleColorEnum), ds.Tables[0].Rows[i]["VEHICLE_COLOR"]);
                ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.ServiceTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE"]);
            }
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        /// <summary>
        /// 获取新版车辆信息
        /// </summary>
        /// <param name="vehicleId">地接客Id</param>
        /// <returns></returns>
        ///  Author:任延华
        ///  Creation date:2015-9-16
        public DataSet GetNewDjackVehicleInfo(string djackId)
        {
            if (string.IsNullOrEmpty(djackId))
            {
                return new DataSet();
            }
            CDbParmCollection parmCollection = new CDbParmCollection();
            parmCollection.Add(new CDbParm("djackId", ParameterDirection.Input, EDbType.String, 36, djackId));

            DataSet ds = this.DataObj.QueryBySQL(@" SELECT VEHICLE_NAME,VEHICLE_INFO_ID,LICENSE_PLATE_NUMBER,VEHICLE_BUY_TIME,VEHICLE_SEATS,VEHICLE_PRICE_DAY,VEHICLE_SERVICE_AREA,VEHICLE_TYPE,VEHICLE_BRAND,VEHICLE_COLOR,VEHICLE_SERVICE_TYPE,VEHICLE_DEFAULT_PIC 
  ,B.COUNTRY_CITY_NME D_NAME,C.COUNTRY_CITY_NME CITY_NAME,D.COUNTRY_CITY_NME COUNTRY_NAME
  FROM DJK_VEHICLE_INFO A
	LEFT JOIN DJK_COUNTRY_CITY B ON A.VEHICLE_DESTINATION=B.COUNTRY_CITY_ID
	LEFT JOIN DJK_COUNTRY_CITY C ON A.VEHICLE_CITY=C.COUNTRY_CITY_ID 
	LEFT JOIN DJK_COUNTRY_CITY D ON A.VEHICLE_COUNTRY=D.COUNTRY_CITY_ID
   WHERE DJACK_ID=@djackId", parmCollection);
            ds.Tables[0].Columns.Add("VEHICLE_BRAND_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_TYPE_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_COLOR_NAME", typeof(string));
            ds.Tables[0].Columns.Add("VEHICLE_SERVICE_TYPE_NAME", typeof(string));

            for (int i = ds.Tables[0].Rows.Count - 1; i >= 0; i--)
            {
                ds.Tables[0].Rows[i]["VEHICLE_BRAND_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleBrandEnum), ds.Tables[0].Rows[i]["VEHICLE_BRAND"]);
                ds.Tables[0].Rows[i]["VEHICLE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_TYPE"]);
                ds.Tables[0].Rows[i]["VEHICLE_COLOR_NAME"] = Enum.GetName(typeof(CommonEnum.VehicleColorEnum), ds.Tables[0].Rows[i]["VEHICLE_COLOR"]);
                ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE_NAME"] = Enum.GetName(typeof(CommonEnum.ServiceTypeEnum), ds.Tables[0].Rows[i]["VEHICLE_SERVICE_TYPE"]);
            }
            ds.Tables[0].TableName = this.TableName;
            return ds;
        }

        /// <summary>
        /// 平台修改车辆
        /// </summary>
        /// <param name="vehicleId">车辆Id</param>
        /// <param name="name">车辆名称</param>
        /// <param name="buyTime">购买时间</param>
        /// <param name="seats">座位数</param>
        /// <param name="price">价格</param>
        /// <param name="serviceArea">服务范围</param>
        /// <param name="carType">车辆类型</param>
        /// <param name="brand">车辆品牌</param>
        /// <param name="color">车辆颜色</param>
        /// <param name="serviceType">服务类型</param>
        /// <param name="picture">车辆图片</param>
        /// <param name="vehicleNumber">车牌号</param>
        /// <returns>修改结果</returns>
        ///  Author:任延华
        ///  Creation date:2014-9-11
        public string UpdateNewVehicle(string vehicleId, string name, string buyTime, string seats, string price, string serviceArea, string carType, string brand, string color, string serviceType, string picture, string vehicleNumber)
        {
            #region 非空判断
            if (string.IsNullOrEmpty(vehicleId) &&
                string.IsNullOrEmpty(name) &&
                string.IsNullOrEmpty(buyTime) &&
                string.IsNullOrEmpty(seats) &&
                string.IsNullOrEmpty(price) &&
                string.IsNullOrEmpty(serviceArea) &&
                string.IsNullOrEmpty(carType) &&
                string.IsNullOrEmpty(brand) &&
                string.IsNullOrEmpty(color) &&
                string.IsNullOrEmpty(serviceType) &&
                string.IsNullOrEmpty(vehicleNumber) &&
                string.IsNullOrEmpty(picture))
            {
                return "车辆信息不完整";
            }
            #endregion

            #region 格式验证
            if (!CommValiCollection.IsNumber(price))
            {
                return "价格只能是数字";
            }
            if (!CommValiCollection.IsNumber(seats))
            {
                return "车辆座位数只能是正整数";
            }
            //日期判断
            if (!CommValiCollection.IsDate(buyTime))
            {
                return "车辆购买时间格式不正确";
            }
            //车名长度判断
            if (CommValiCollection.GetStrLength(name) > 40)
            {
                return "车辆名称少于40字符";
            }
            #endregion

            #region 非法验证
            int carColor = 1; //车辆颜色
            int.TryParse(color, out carColor);
            int adultsNum = 4; //可载人数
            int.TryParse(seats, out adultsNum);
            DateTime useTime = DateTime.Now;//上户时间
            DateTime.TryParse(buyTime, out useTime);
            int serverType = 1;//服务类型
            int.TryParse(serviceType, out serverType);
            int vehiclelBrand = 1;//车辆品牌
            int.TryParse(brand, out vehiclelBrand);
            decimal carPrice = 0;//车辆价格
            decimal.TryParse(price, out carPrice);
            int vehiclelType;
            int.TryParse(carType, out vehiclelType);

            if (int.MaxValue < adultsNum || adultsNum <= 0)
            {
                return "车辆座位数不正确";
            }
            if (carPrice <= 0 || carPrice > 100000000)
            {
                return "车辆价格不正确";
            }
            #endregion
            DataSet ds = GetNewVehicleInfo(vehicleId);
            if (ds.Tables[0].Rows.Count <= 0)
            {
                return "该车辆不存在";
            }
            ds.Tables[0].Rows[0]["VEHICLE_NAME"] = name;
            ds.Tables[0].Rows[0]["VEHICLE_BRAND"] = vehiclelBrand;
            ds.Tables[0].Rows[0]["VEHICLE_TYPE"] = vehiclelType;
            ds.Tables[0].Rows[0]["VEHICLE_SEATS"] = adultsNum;
            ds.Tables[0].Rows[0]["VEHICLE_COLOR"] = carColor;
            ds.Tables[0].Rows[0]["VEHICLE_SERVICE_TYPE"] = serverType;
            ds.Tables[0].Rows[0]["VEHICLE_BUY_TIME"] = buyTime;
            ds.Tables[0].Rows[0]["VEHICLE_PRICE_DAY"] = carPrice;
            ds.Tables[0].Rows[0]["VEHICLE_SERVICE_AREA"] = serviceArea;
            ds.Tables[0].Rows[0]["VEHICLE_DEFAULT_PIC"] = picture;
            ds.Tables[0].Rows[0]["LICENSE_PLATE_NUMBER"] = vehicleNumber;

            this.Update(ds);
            return "OK";
        }
    }

    /// <summary>
    /// 车辆状态枚举
    /// </summary>
    public enum VehicleStatusEnum
    {
        /// <summary>
        /// 审核中
        /// </summary>
        审核中 = 1,
        /// <summary>
        /// 通过审核
        /// </summary>
        通过审核 = 2,
        /// <summary>
        /// 未通过审核
        /// </summary>
        未通过审核 = 3,
        /// <summary>
        /// 全部
        /// </summary>
        全部 = 0
    }

}
